﻿ <!DOCTYPE html>
<html lang="en">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta http-equiv="content-type" content="text/html;charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>登陆</title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
	<link rel="shortcut icon" href="home.png">
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/vector.js"></script>

</head>

<body>

    <div id="container">
    	
        <div id="output">
            <div class="containerT">
		        
                <h1>用户登录</h1>
                <form class="form" id="entry_form">
                    <input type="text" placeholder="用户名" id="entry_name" hidden="admin">
                    <input type="password" placeholder="密码" id="entry_password">
                    <button type="button" id="entry_btn">登录</button>
                    <div id="prompt" class="prompt"></div>
                </form>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(function() {
            Victor("container", "output"); //登录背景函数
            //聚焦在输入框
            $("#entry_name").focus();
            //点击回车的响应
            $(document).keydown(function(event) {
                if (event.keyCode == 13) {
                    $("#entry_btn").click();
                }
            });
            //登录按钮的点击响应
            $("#entry_btn").click(function() {
            	 var user = new Object();
            	    user.loginCode = $.trim($("#entry_name").val());
            	    user.password = $.trim($("#entry_password").val());
            	 
            	    //前台的非空验证
            	    if(user.loginCode == "" || user.loginCode == null){
            	    	alert("对不起，登录账号不能为空。");
            	        
            	    }else if(user.password == "" || user.password == null){
            	    	alert("对不起，登录密码不能为空。");
            	    }else {
            	    	//ajax验证用户名密码对不对
            	    	$.ajax({
            	    		url:"/MyWebPlus/Enter",
            	    		data:{"name":user.loginCode,password:user.password},
            	    		dataType:"text",
            	    		success:function(data){
            	    			// 非零即对  根据是学生1还是教师2转入不同的页面
            	    			if(data=="0"){
            	    				alert("用户名或密码错误");
            	    			}else if(data=="1"){
            	    				window.location.href = "../student/message/message.html?id="+user.loginCode+"";
            	    			}else if(data=="2"){
            	    				window.location.href = "../adminer/home/index.html?id="+user.loginCode+"";
            	    			}
            	    		}
            	    	});
            	    	                  	    	
            	    }
               
            });
        });
    </script>
    <div style="text-align:center;">
        <p></p>
    </div>
</body>

</html>